<template>
  <div class="p-4">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <div class="flex mt-3">
          <el-form inline>
            <el-form-item label="用户Id">
              <el-input
                v-model="listQuery.give_user_code"
                placeholder="请输入用户Id"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item label="用户昵称">
              <el-input
                v-model="listQuery.give_user_nickname"
                placeholder="请输入用户昵称"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item label="开始时间:">
              <el-date-picker
                placeholder="请选择开始时间"
                v-model="listQuery.start_time"
                type="date"
                value-format="yyyy-MM-dd"
                clearable
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item label="结束时间:">
              <el-date-picker
                placeholder="请选择结束时间"
                v-model="listQuery.end_time"
                type="date"
                value-format="yyyy-MM-dd"
                clearable
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button @click="handleClick" type="primary">搜索</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>

      <el-table :data="data" border>
        <el-table-column
          prop="give_user_code"
          label="送礼Id"
          width="150px"
        ></el-table-column>

        <el-table-column
          prop="give_user_nickname"
          label="送礼昵称"
        ></el-table-column>
        <el-table-column
          prop="gift_name"
          label="亲密道具昵称"
        ></el-table-column>
        <el-table-column
          prop="receive_user_code"
          label="收礼Id"
        ></el-table-column>
        <el-table-column
          prop="receive_user_nickname"
          label="收礼昵称"
        ></el-table-column>
        <el-table-column
          prop="winner_gift_name"
          label="产生道具"
        ></el-table-column>
        <el-table-column prop="created_at" label="赠送时间"></el-table-column>
      </el-table>
      <cus-pagination
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.page_size"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import { giveRecord } from "@/api/intimacyGift/giftRecordQuery";
export default {
  data() {
    return {
      data: [],
      listQuery: {
        give_user_code: null,
        give_user_nickname: undefined,
        start_time: "",
        end_time: "",
        page: 1,
        page_size: 10
      },
      total: 0
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //列表
    getList() {
      giveRecord(this.listQuery).then(res => {
        this.data = res.data.data;
        this.total = res.data.total;
      });
    },
    handleClick() {
      if (
        this.listQuery.start_time <= this.listQuery.end_time &&
        this.listQuery.start_time &&
        this.listQuery.end_time
      ) {
        this.getList();
      } else {
        this.$message.error("请选择正确的时间");
      }
    }
  }
};
</script>
<style lang="scss" scoped></style>
